<?php
/**
 * 获取数据中所有集合示例
 * Created by PhpStorm.
 * User: bimUser
 * Date: 2018/1/20
 * Time: 12:30
 */

require 'config.php';
require 'vendor/autoload.php';

// 实例化连接
$db = new MongoDB\Client("mongodb://{$cnf['USERNAME']}:{$cnf['PASSWD']}@{$cnf['HOST']}:{$cnf['PORT']}/{$cnf['DBNAME']}");

// 获取数据库中的所有集合名称
$database = $db->test;

foreach ($database->listCollections() as $collectionInfo) {
    var_dump($collectionInfo->getName());
}
